//cookie的相关函数
function getCookieVal (offset) { 
 var endstr = document.cookie.indexOf (";", offset); 
 if (endstr == -1) endstr = document.cookie.length; 
    return unescape(document.cookie.substring(offset, endstr)); 
 }     
 function getCookie (name) {
         var arg = name + "="; 
         var alen = arg.length; 
         var clen = document.cookie.length; 
         var i = 0; 
         while (i < clen) { 
             var j = i + alen; 
             if (document.cookie.substring(i, j) == arg) return getCookieVal (j); 
             i = document.cookie.indexOf(" ", i) + 1; 
             if (i == 0) break; 
         } 
      return null; 
 } 
function setCookie (name, value) { 
       var exp = new Date(); 
       exp.setTime (exp.getTime()+3600000000); 
       document.cookie = name + "=" + value + "; expires=" + exp.toGMTString(); 
}
////////////////////////////////////
function mmcick(tplpath,pagetitle)
{
	window.parent.document.getElementById("pagetitle").innerHTML=pagetitle;
	var evt=evt?evt:window.event;
	var srcElem=(evt.srcElement)?evt.srcElement:evt.target;
	try
	{
		while(srcElem.parentNode&&srcElem!=srcElem.parentNode)
		{
			if(srcElem.tagName&&srcElem.tagName.toUpperCase()=="A")
			{
				linkname=srcElem.innerHTML;
				address=srcElem.href+"_miceCMS_";
				wlink=linkname+"+"+address; 
				old_info=getCookie("miceCMS_history_menu");
				var insert=true; 
				////////////////////////
				if(old_info==null)//判断cookie是否为空
				{
					insert=true;
				}
				else
				{ 
					var old_link=old_info.split("_miceCMS_");
					for(var j=0;j<=5;j++)
					{
						if(old_link[j].indexOf(linkname)!=-1)
							insert=false;
						if(old_link[j]=="null")
							break;
					}
				 }
				 /////////////////////////////
				if(insert)                //如果符合条件则重新写入数据
				{
					wlink+=getCookie("miceCMS_history_menu");
					setCookie("miceCMS_history_menu",wlink);
					history_show(tplpath).reload();
					break;
				}
			}
			srcElem = srcElem.parentNode;
		}
	}
	catch(e){}
	return true;
}
//////////////////////////////////////////////////////////////////////////////// 
function history_show(tplpath)
{
	var miceCMS_history_menu=getCookie("miceCMS_history_menu");
	var content=""; 
	if(miceCMS_history_menu!=null)
	{
		history_arg=miceCMS_history_menu.split("_miceCMS_");
		var i;
		for(i=0;i<=5;i++)
		{
			
			if(typeof(history_arg[i])!="undefined" && history_arg[i]!="null")
			{
				var wlink=history_arg[i].split("+");
				content+=("<td>&nbsp;<a href='"+wlink[1]+"' target='content'>"+wlink[0]+"</a>&nbsp;</td><td width='10' align='center' valign='middle'><img src='"+tplpath+"imgs/top-line.gif' width='2' height='14' /></td>");
			}
			window.parent.document.getElementById("history").innerHTML=content;
	   }
	}
	else
	{
		window.parent.document.getElementById("history").innerHTML="对不起，您没有任何浏览纪录";
	}
}